/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package datamodel;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import javax.persistence.*;

/**
 *
 * @author eXtreme
 */
@Entity
@javax.persistence.NamedQuery(name = "showAdmins", query = "SELECT a FROM SystemUser a WHERE DTYPE = :SystemAdministrator")
public class SystemAdmin extends SystemUser implements Serializable {

    // -----------------------    
    private static final long serialVersionUID = 1L;
    @OneToMany(mappedBy = "solvedBy")
    @OrderBy("created DESC")
    protected Set<Ticket> solving;
    @ManyToMany
    @JoinTable(
        name="can_solve",
        joinColumns=
            @JoinColumn(name="user_id", referencedColumnName="user_id"),
        inverseJoinColumns=
            @JoinColumn(name="category_id", referencedColumnName="category_id")
    )
    private List<Category> canSolve;
    // -----------------------

    public SystemAdmin() {
    }

    public SystemAdmin(String name, String surname, String email, String password) {
        this.name = name;
        this.surname = surname;
        this.email = email;
        this.password = password;
    }

    public List<Category> getCanSolve() {
        return canSolve;
    }

    public void setCanSolve(List<Category> canSolve) {
        this.canSolve = canSolve;
    }

    public Set<Ticket> getSolving() {
        return solving;
    }

    public void setSolving(Set<Ticket> solving) {
        this.solving = solving;
    }

    @Override
    public String toString() {
        return getName() + " " + getSurname();
    }
    
    @Override
    public String getRole() {
        return "Administrátor";
    }
}
